<meta charset="utf-8">
<title>股东管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="description" content="网站描述">
<meta name="keywords" content="">
<meta name="author" content="wangl">
<link rel="icon" href="http://ow9lg82yy.bkt.clouddn.com/24f5c360-485d-4a6d-9468-2a61c353cf37.ico">
<link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all">
<link rel="stylesheet" href="/static/css/user.css" media="all">
<link rel="stylesheet" href="/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">

<style>
    .layui-table-cell {
        padding: 0 5px;
    }

    .layui-table td, .layui-table th {
        padding: 9px 5px;
    }
</style>

</head>
<body class="childrenBody">
<div class="layui-col-xs2">
    <div class="grid-demo grid-demo-bg1">
        <ul id="treeDemo" class="ztree"></ul>
    </div>
</div>
<div class="layui-col-xs12">
    <fieldset class="layui-elem-field">
        <legend>股东列表</legend>
        <div class="layui-field-box">
            <form class="layui-form" id="searchForm" action="/back/admin/shareholder/searchPage">
                <div class="layui-inline" style="margin-left: 15px">
                    <label>姓名:</label>
                    <div class="layui-input-inline">
                        <input id="userName" type="text" value="" name="userName" placeholder="姓名"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>手机号:</label>
                    <div class="layui-input-inline">
                        <input id="phoneNum" type="text" value="" name="phoneNum" placeholder="手机号"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>证件号码:</label>
                    <div class="layui-input-inline">
                        <input id="idCardNum" type="text" value="" name="idCardNum" placeholder="证件号码"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>股东等级:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="lowLevel" id="lowLevel" lay-verify="date"
                               autocomplete="off" class="layui-input" lay-key="1">
                    </div>
                    <span>-</span>
                    <div class="layui-input-inline">
                        <input type="text" name="highlevel" id="highlevel" lay-verify="date"
                               autocomplete="off" class="layui-input" lay-key="2">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>休眠币数量区间:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="minSleepCoinCount" id="minSleepCoinCount" lay-verify="date"
                               autocomplete="off" class="layui-input" lay-key="1">
                    </div>
                    <span>-</span>
                    <div class="layui-input-inline">
                        <input type="text" name="maxSleepCoinCount" id="maxSleepCoinCount" lay-verify="date"
                               autocomplete="off" class="layui-input" lay-key="2">
                    </div>
                </div>

                <div class="layui-inline" style="margin-left: 15px">
                    <label class="layui-form-label">股东状态</label>
                    <div class="layui-input-block">
                        <select name="memberState" lay-filter="memberState">
                            <option value="0">正常</option>
                            <option value="1">冻结</option>
                            <option value="2">封号</option>
                            <option value="3">未激活</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>活币数量区间:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="minAliveCoinCount" id="minAliveCoinCount" lay-verify="date"
                               autocomplete="off" class="layui-input" lay-key="1">
                    </div>
                    <span>-</span>
                    <div class="layui-input-inline">
                        <input type="text" name="maxAliveCoinCount" id="maxAliveCoinCount" lay-verify="date"
                               autocomplete="off" class="layui-input" lay-key="2">
                    </div>
                </div>

                <div class="layui-inline" style="margin-left: 15px">
                    <label>注册时间区间:</label>
                    <div class="layui-inline">
                        <input type="text" class="layui-input" id="endRegisterTime" name="endRegisterTime"
                               lay-verify="date">
                    </div>
                    <span>-</span>
                    <div class="layui-inline">
                        <input type="text" class="layui-input" name="startRegisterTime" id="startRegisterTime"
                               lay-verify="date">
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="button" class="layui-btn" onclick="sift()">搜索</button>
                </div>
                <div class="layui-inline">
                    <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                </div>
                <div>
                    <div class="layui-inline">
                        <a href="addpage" class="layui-btn layui-btn-normal" data-type="addBlogArticle">新增股东</a>
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn"><a href="/back/content/excel/download">下载股东表格文件</a></button>
                    </div>
                    <div class="layui-btn layui-btn-normal" style="position: relative">选择表格
                        <input type="file" name="fileName" id="file1"
                               style="opacity: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn" id="upload">表格添加股东</button>
                    </div>
                </div>
            </form>
            <#--<form class="layui-form" id="siftForm" action="/back/admin/shareholder/sift">-->
            <#--<div>-->


            <#--&lt;#&ndash;<div class="layui-inline">&ndash;&gt;-->
            <#--&lt;#&ndash;<button type="submit" class="layui-btn" onclick="sift()">筛选</button>&ndash;&gt;-->
            <#--&lt;#&ndash;</div>&ndash;&gt;-->
            <#--</div>-->

            <#--</form>-->

        </div>

    </fieldset>
    <div class="layui-form users_list">

        <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
            <thead>
            <tr>
                <th data-field="userId">
                    <div class="layui-table-cell laytable-cell-1-anid1"><span>编号</span></div>
                </th>
                <th data-field="userRealName">
                    <div class="layui-table-cell laytable-cell-1-anid1"><span>姓名</span></div>
                </th>
                <th data-field="phoneNum">
                    <div class="layui-table-cell laytable-cell-1-title"><span>手机号</span></div>
                </th>
                <th data-field="shareholderLevel">
                    <div class="layui-table-cell laytable-cell-1-anid90"><span>股东等级</span></div>
                </th>
                <th data-field="userState">
                    <div class="layui-table-cell laytable-cell-1-anid90"><span>股东状态</span></div>
                </th>
                <th data-field="sleepCount">
                    <div class="layui-table-cell laytable-cell-1-anid100"><span>休眠币数量</span></div>
                </th>
                <th data-field="aliveCount">
                    <div class="layui-table-cell laytable-cell-1-anid100"><span>活币持有量</span></div>
                </th>
                <th data-field="aliveGrantCount">
                    <div class="layui-table-cell laytable-cell-1-anid100"><span>活币配发量</span>
                    </div>
                </th>
                <th data-field="transferToShareholder">
                    <div class="layui-table-cell laytable-cell-1-anid100"><span>转股东活币</span>
                    </div>
                </th>

                <th data-field="totalBonusCount">
                    <div class="layui-table-cell laytable-cell-1-anid90"><span>累计分红</span></div>
                </th>
                <th data-field="thisMonthBonusCount">
                    <div class="layui-table-cell laytable-cell-1-anid90"><span>本月分红</span></div>
                </th>
                <th data-field="registerTime" data-unresize="true">
                    <div class="layui-table-cell laytable-cell-1-publistTime"><span>注册时间</span></div>
                </th>
                <th data-field="9" style="width: 160px;">
                    <div class="layui-table-cell laytable-cell-1-9" align="center"><span>操作</span></div>
                </th>
            </tr>
            </thead>
            <tbody id="anList">
            </tbody>
        </table>
        <div class="box-tools pull-right">
            <ul class="pagination" id="pagination_ul">
            </ul>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/tools.js"></script>
<script type="text/javascript" src="/static/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/static/js/CodeConst.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script>
    //遍历baseDto
    function loadData(baseDto) {
        if (baseDto.code == ERROR)
            console.log(baseDto.msg);
        else {
            //数据
            var shareholderList = baseDto.data.list;
            var text = "";
            var opreate = "";
            console.log(shareholderList);
            $.each(shareholderList, function (index, shareholderList) {
                if (shareholderList.user.state == 0) {
                    opreate = "<td class=\"text-center\" align=\"center\">\n" +
                        "    <a href='/back/admin/admin/close?userId=" + shareholderList.userId + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">封号</a>\n" +
                        "    <a href='/back/admin/admin/frozen?userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">冻结</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        "    <a href='/back/admin/shareholder/shareholderInfoPage?userType=2&userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">股东信息</a>\n" +
                        "</td>\n"
                } else if (shareholderList.user.state == 1) {
                    opreate = "<td class=\"text-center\" align=\"center\">\n" +
                        "    <a href='/back/admin/admin/close?userId=" + shareholderList.userId + "'    type=\"button\" class=\"layui-btn layui-btn-xs\">封号</a>\n" +
                        "    <a href='/back/admin/admin/unfrozen?userId=" + shareholderList.userId + "&userType=2' type=\"button\" class=\"layui-btn layui-btn-xs\">解冻</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        "    <a href='/back/admin/shareholder/shareholderInfoPage?userType=2&userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">股东信息</a>\n" +
                        "</td>\n"
                } else if (shareholderList.user.state == 2) {
                    opreate = "<td class=\"text-center\" align=\"center\">\n" +
                        "    <a href='/back/admin/admin/unclose?userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">解封</a>\n" +
                        "    <a href='/back/admin/admin/frozen?userId=" + shareholderList.userId + "&userType=2'   type=\"button\" class=\"layui-btn layui-btn-xs\">冻结</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        "    <a href='/back/admin/shareholder/shareholderInfoPage?userType=2&userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">股东信息</a>\n" +
                        "</td>\n"
                } else if (shareholderList.user.state == 3) {
                    opreate = "<td class='text-center' align='center' > \n" +
                        "    <a href='/back/admin/admin/active?userId=" + shareholderList.userId + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">激活</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        "    <a href='/back/admin/shareholder/shareholderInfoPage?userType=2&userId=" + shareholderList.userId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">股东信息</a>\n" +
                        "</td>\n"
                }
                text += "<tr>\n" +
                    "<td>" + shareholderList.userId + "</td>\n" +
                    "<td>" + shareholderList.userRealName + "</td>\n" +
                    "<td>" + shareholderList.phoneNum + "</td>\n" +
                    "<td>" + shareholderList.shareholderLevel + "</td>\n" +
                    "<td>" + shareholderList.userStateName + "</td>\n" +
                    "<td>" + shareholderList.sleepCount + "</td>\n" +
                    "<td>" + shareholderList.aliveCount + "</td>\n" +
                    "<td>" + "<a href='/dividenshistorypage?userId=" + shareholderList.userId + "' onclick='setCommonParam(" + shareholderList.userId + ")'  type=\"button\" class=\"layui-btn layui-btn-xs\">" + shareholderList.aliveGrantCount + "</a>\n" + "</td>\n" +
                    "<td>" + "<a href='/back/admin/shareholder/sTosTransferPage?userId=" + shareholderList.userId + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">" + shareholderList.transferToShareholder + "</a>\n" + "</td>\n" +
                    "<td>" + "<a href='/back/finance/dividends/userPage?userId=" + shareholderList.userId + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">" + shareholderList.totalBonusCount + "</a>\n" + "</td>\n" +
                    "<td>" + "<a href='/back/finance/dividends/userMonthPage?userId=" + shareholderList.userId + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">" + shareholderList.thisMonthBonusCount + "</a>\n" + "</td>\n" +
                    "<td>" + shareholderList.registerTime + "</td>\n" +
                    opreate
                "</tr>";
            });
            console.log(opreate)
            var anListDom = $("#anList");
            anListDom.empty();//清空子元素
            anListDom.append($(text));
            //
            // var pages = baseDto.data.pages;
            // var pageNum = baseDto.data.pageNum;
            // console.log("pageNum=" + pageNum);
            // var btnList = "";
            // btnList += "<li class='first_page'><a onclick='loadPage(this)' link='/back/content/an/list'>" + "首页" + "</a></li>";
            // var temp = "<li class='prepage'><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + (pageNum - 1) + "'>上一页</a></li>";
            // console.log("temp=" + temp);
            // btnList += temp;
            // for (var i = 0; i < pages; i++) {
            //     btnList += ("<li class='prepage'><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + (i + 1) + "'>" + (i + 1) + "</a></li>\n")
            // }
            // btnList += ("<li class='nextpage'><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + (pageNum + 1) + "'>下一页</a></li>\n" +
            //     "<li class='last_page' ><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + pages + "'>末页</a></li>");
            // console.log(btnList);
            // var pagination_ul = $("#pagination_ul");
            // pagination_ul.empty();
            // pagination_ul.append(btnList);


        }
    }

    //    function loadPages(pageNum)
    //    {
    //        loadPage("/back/admin/shareholder/search",pageNum,function (data) {
    //            loadData(data);
    //        })
    //    }
    loadPage("/back/admin/shareholder/search", 1, function (data) {
        loadData(data);
    })


    var laypage = 0;

    layui.use(['laypage', 'layer'], function () {
        // laypage = layui.laypage;
        var laypage = layui.laypage
            , layer = layui.layer;

        $.ajax({
            url: "/back/admin/shareholder/search",
            type: "GET",
            success: function (baseDto) {
                loadData(baseDto);
                baseDto = baseDto.data;
                laypage.render({
                    elem: 'pagination_ul'
                    , count: baseDto.total
                    , curr: baseDto.fristPage //获取起始页
                    , limit: 10
                    , jump: function (obj) {
                        loadPage(obj.curr);
                    }

                });
            }
        });

        function loadPage(pageNum) {
            $.get("/back/admin/shareholder/search?pageNum=" + pageNum, function (baseDto) {
                loadData(baseDto);
            })
        }
    });

    //    $.ajax({
    //        url: "/back/admin/shareholder/list",
    //        type: "GET",
    //        success: function (baseDto) {
    //            loadData(baseDto);
    //            baseDto = baseDto.data;
    //            laypage.render({
    //                elem: 'pagination_ul'
    //                ,count: baseDto.total
    //                ,curr: baseDto.fristPage //获取起始页
    //                ,limit: 10
    //                ,jump: function (obj) {
    //                    loadPages(obj.curr);
    //                }
    //
    //            });
    //        }
    //    });


    function search() {
        var userName = $("#userName").val();
        var phoneNum = $("#phoneNum").val();
        var idCardNum = $("#idCardNum").val();
        //获取数据
        $.ajax({
            url: "/back/admin/shareholder/search",
            type: "GET",
            dataType: "json",
            data: {
                userName: userName,
                phoneNum: phoneNum,
                idCardNum: idCardNum
            },
            success: function (baseDto) {
                loadData(baseDto);
            }
        });
    }


    $("#upload").click(function () {

        $.ajax({
            url: "/back/user/shareholder/uploadExcel",
            type: "POST",
            data: new FormData(document.getElementById('searchForm')),
            /**
             *必须false才会自动加上正确的Content-Type
             */
            contentType: false,
            /**
             * 必须false才会避开jQuery对 formdata 的默认处理
             * XMLHttpRequest会对 formdata 进行正确的处理
             */
            processData: false,
            success: function (data) {
                printJson(data);
                if (data.status == "true") {
                    alert("上传成功！");
                }
                if (data.status == "error") {
                    alert(data.msg);
                }
            },
            error: function () {
                alert("上传失败！");
                $("#imgWait").hide();
            }
        });
    });

    function sift() {
        var lowLevel = $("#lowLevel").val();
        var highlevel = $("#highlevel").val();
        var minSleepCoinCount = $("#minSleepCoinCount").val();
        var maxSleepCoinCount = $("#maxSleepCoinCount").val();
        var shareholderState = $("#shareholderState").val();
        var minAliveCoinCount = $("#minAliveCoinCount").val();
        var maxAliveCoinCount = $("#maxAliveCoinCount").val();
        var endRegisterTime = $("#endRegisterTime").val();
        var startRegisterTime = $("#startRegisterTime").val();

        var userName = $("#userName").val();
        var phoneNum = $("#phoneNum").val();
        var idCardNum = $("#idCardNum").val();
        //获取数据
        $.ajax({
            url: "/back/admin/shareholder/search",
            type: "GET",
            dataType: "json",
            data: {
                userName: userName,
                phoneNum: phoneNum,
                idCardNum: idCardNum,
                lowLevel: lowLevel,
                highlevel: highlevel,
                minSleepCoinCount: minSleepCoinCount,
                maxSleepCoinCount: maxSleepCoinCount,
                shareholderState: shareholderState,
                minAliveCoinCount: minAliveCoinCount,
                maxAliveCoinCount: maxAliveCoinCount,
                endRegisterTime: endRegisterTime,
                startRegisterTime: startRegisterTime,
            },
            success: function (baseDto) {
                loadData(baseDto);
                baseDto = baseDto.data;
                // laypage.render({
                //     elem: 'pagination_ul'
                //     ,count: baseDto.total
                //     ,curr: baseDto.fristPage //获取起始页
                //     ,limit: 10
                //     ,jump: function (obj) {
                //         loadPage(obj.curr);
                //     }
                //
                // });
            }
        });
    }


    layui.use(['form', 'laydate', 'laypage'], function () {
        var form = layui.form;
        var laydate = layui.laydate;
        var laypage = layui.laypage;
        form.render('select', 'memberState');
        laydate.render({
            elem: '#endRegisterTime',
            type: 'datetime'
        });

        laydate.render({
            elem: '#startRegisterTime',
            type: 'datetime'
        });

        // laypage.render({
        //     elem: 'pageTest' //注意，这里的 test1 是 ID，不用加 # 号
        //     ,count: 50 //数据总数，从服务端得到
        // });

    });


</script>
